//
//  UIBarButtonItem+Extension.m
//  欢乐美食
//
//  Created by 遇水 on 15/5/30.
//  Copyright (c) 2015年 遇水. All rights reserved.
//

#import "UIBarButtonItem+Extension.h"
#import "UIView+Extension.h"
@interface UIBarButtonItem ()


@end
@implementation UIBarButtonItem (Extension)
+(UIBarButtonItem*)itemWithImageName:(NSString*)imageName target:(id)target action:(SEL)action{
    UIButton *button = [[UIButton alloc]init];
    [button setBackgroundImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    
    button.size = button.currentBackgroundImage.size;
    
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];

    return [[UIBarButtonItem alloc]initWithCustomView:button];
}
-(UIBarButtonItem*)itemWithImageName:(NSString*)imageName target:(id)target action:(SEL)action{
    UIButton *button = [[UIButton alloc]init];
    [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    
    button.size = button.currentBackgroundImage.size;
    
    //[button setTitle:title forState:UIControlStateNormal];
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return [[UIBarButtonItem alloc]initWithCustomView:button];
}


@end
